package com.itheima.service.impl;

import com.itheima.common.entity.Result;
import com.itheima.pojo.dto.MemberDTO;
import com.itheima.service.MemberService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import static com.itheima.common.utils.SmsUtil.verifyVerificationCode;

@Service
@Slf4j
public class MemberServiceImpl implements MemberService {
    @Override
    public Result login(MemberDTO memberDTO) {
        String phoneNumber=memberDTO.getTelephone();
        String userInputCode=memberDTO.getValidateCode();
        boolean result = verifyVerificationCode(phoneNumber, userInputCode);
        if (result) {
            log.info("验证码正确！");
            return new Result(true,"验证码验证成功");
        } else {
            log.info("验证码错误或已过期！");
            return new Result(false,"验证码输入错误");
        }

    }
}
